package com.imau.common;

import lombok.Data;

@Data
public class CommonResult{
    //成功失败标志
    private boolean   success;

    //code
    private Integer code;

    //message
    private String message;

    //data

    private Object data;

    //预制一些静态方法 ，快速
    public CommonResult(ResultCode code)
    {
        this.success = code.getSuccess();
        this.code = code.getCode();
        this.message=code.getMessage();
    }


    public CommonResult(ResultCode code,Object data)
    {
        this.success = code.getSuccess();
        this.code = code.getCode();
        this.message=code.getMessage();
        this.data =data;
    }

    public CommonResult(Integer code,String message,boolean success) {

        this.code = code;
        this.message = message;
        this.success = success;
    }

    public static CommonResult SUCCESS(){

        return new CommonResult(ResultCode.SUCCESS);
    }

    public static CommonResult ERROR()
    {
        return  new CommonResult(ResultCode.SERVER_ERROR);
    }

    public static CommonResult FAIL()
    {
        return  new CommonResult(ResultCode.FAIL);
    }

}
